home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / b / b.lha / B / src / bint / Change < prev    next >
Encoding:
Text File  |  1988-11-24  |  1.1 KB  |  48 lines

  1. : 'Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. '
  2. : '$Header: Change,v 1.1 85/08/22 16:38:36 timo Exp $'
  3.  
  4. : 'Change error messages in limited number of files'
  5.  
  6. case $1 in
  7. [0-9]*) start=$1; shift;
  8.     case $1 in
  9.     [0-9]*) step=$1; shift;;
  10.     *) step=100;
  11.     esac;;
  12. *)    start=100; step=100;;
  13. esac
  14.  
  15. for file
  16. do
  17.     if test -f @$file
  18.     then
  19.         echo @$file already exists, $file skipped
  20.     else
  21.         mv $file @$file || exit
  22.         echo $file $start
  23.         sed 's/pprerr2 *( *\(.*\) *, *\(".*"\));/pprerr2(\1, MESS($, \2));/
  24.              s/fixerr2 *( *\(.*\) *, *\(".*"\));/fixerr2(\1, MESS($, \2));/
  25.              s/\(err[a-z]*[23]*\) *( *\(".*"\)/\1(MESS($, \2)/
  26.              s/MESS([0-9\$]*/MESS($/' @$file |
  27.         awk "BEGIN {messnum=$start}"'
  28.             /MESS\(/ {n=split($0, field, "$");
  29.              if (n==2) {print field[1] messnum field[2]; ++messnum}
  30.              else print
  31.             }
  32.             !/MESS\(/ {print}' >$file
  33.         if test -s $file
  34.         then
  35.             if cmp -s @$file $file
  36.             then
  37.                 mv @$file $file
  38.                 echo $file unchanged
  39.             else
  40.                 start=`expr $start + $step`
  41.             fi
  42.         else
  43.             mv @$file $file
  44.             echo $file clobbered, old version put back
  45.         fi
  46.     fi
  47. done
  48.